This invention relates to software applications for handling multiple asynchronous data streams. In particular, it relates to an operating-system-independent modular programming method and its application to a storage device controller to accomplish robust just-in-time response to multiple asynchronous data streams.